package com.system.boot.company.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.system.api.company.entity.po.SysCompany;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 企业
 *
 * @author: lslands
 * @description:
 * @version：v1.0
 * @date: 2024/6/1 21:31
 */
@Mapper
public interface CompanyMapper extends BaseMapper<SysCompany> {


    /**
     * 校验指定字段是否重复
     * @param field 字段
     * @param params 被校验参数
     * @return boolean
     * @author lslands
     * @date 2024/5/16 00:39
     */
    @Select("SELECT EXISTS(SELECT 1 FROM sys_company WHERE #{field}=#{params})")
    boolean getExistsByParams(String field,String params);


    /**
     * 查询指定公司及其子公司
     * @param companyId 公司id
     * @return SysCompany
     * @author lslands
     */
    List<SysCompany> withList(@Param("companyId") Long companyId);


    /**
     * 批量删除(物理)
     * @param ids 主键
     * @author lslands
     * @date 2024/5/16 00:57
     * @return int
     */
    int deleteBatch(@Param("ids") List<Long> ids);

}
